package com.ruoyi.project.bi.domain.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

@Data
@TableName("bi_kpi_list")
public class Measure extends CubeColMeta {

	@TableId(value = "rid",type = IdType.AUTO)
	private Integer kpiId;
	@TableField("kpi_name")
	private String name;
	@TableField("kpi_desc_key")
	private String kpinote;
	private String unit;
	private String fmt;
	private String aggre;
	private String alias;
	/** 0否，1是 */
	private Integer calcKpi;
	private Integer cubeId;

	/** 获取聚合字段字符串 */
	public String getAggreCol() {
		/** 需要特殊处理 */
		if("count(distinct)".equals(aggre)){
			return "count(distinct " + super.getCol() + ")";
		}else{  //sum/avg/max/min/count 不需要特殊处理
			return aggre +"(" + super.getCol() +")";
		}
	}

}
